package com.jx.controller;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import com.jx.dao.DepDao;
import com.jx.daoimpl.DepDaoImpl;
import com.jx.model.Admin;

import com.jx.service.DepService;
import com.jx.service.FuncService;
import com.jx.servicrimpl.DepServiceImpl;
import com.jx.servicrimpl.FuncServiceImpl;
/**
 * 展示功能界面的servlet
 * @author yu
 *
 */
public class ShowFuncsController extends HttpServlet{
	    DepService depservice = new DepServiceImpl();
	    FuncService funcservice = new FuncServiceImpl();
          @Override
        protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        	// TODO Auto-generated method stub
        	super.doGet(req, resp);
        }
          @Override
        protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        // TODO Auto-generated method stub
        	  req.setCharacterEncoding("utf8");
			  resp.setCharacterEncoding("utf8");
        	  PrintWriter  pw  =  resp.getWriter();
        	  HttpSession session =  req.getSession();
        	  Admin admin =(Admin)session.getAttribute("currentadmin");
        	  String aname = admin.getAname();
        	  String s = depservice.getFuncsByAname(aname);
        	  pw.write(funcservice.getFuncs(-1, s).toString());
              
        }
		
}
